require File.expand_path('../../lib/r_type', __FILE__)

R.run do
  print RType::Matrix.zero 3
  print RType::Matrix.I 3

  a = RType::Matrix[[1, 3], [2, 4]]
  b = RType::Matrix[[0, 2], [1, 3]]

  print t(a)
  print a + b - a * b

  print outer(a, b)
  print kronecker(a, b)

  print a * [1, 2]
  print 1 / a

  x = matrix (1..9).to_a, ncol: 3
  print upper_tri(x)
  print x
end
# >>      [,1] [,2] [,3]
# >> [1,]    0    0    0
# >> [2,]    0    0    0
# >> [3,]    0    0    0
# >>      [,1] [,2] [,3]
# >> [1,]    1    0    0
# >> [2,]    0    1    0
# >> [3,]    0    0    1
# >>      [,1] [,2]
# >> [1,]    1    2
# >> [2,]    3    4
# >>      [,1] [,2]
# >> [1,]   -2   -6
# >> [2,]   -1   -9
# >> , , 1, 1
# >>
# >>      [,1] [,2]
# >> [1,]    0    0
# >> [2,]    0    0
# >>
# >> , , 2, 1
# >>
# >>      [,1] [,2]
# >> [1,]    1    3
# >> [2,]    2    4
# >>
# >> , , 1, 2
# >>
# >>      [,1] [,2]
# >> [1,]    2    6
# >> [2,]    4    8
# >>
# >> , , 2, 2
# >>
# >>      [,1] [,2]
# >> [1,]    3    9
# >> [2,]    6   12
# >>
# >>      [,1] [,2] [,3] [,4]
# >> [1,]    0    2    0    6
# >> [2,]    1    3    3    9
# >> [3,]    0    4    0    8
# >> [4,]    2    6    4   12
# >>      [,1]
# >> [1,]    7
# >> [2,]   10
# >>      [,1]      [,2]
# >> [1,]  1.0 0.3333333
# >> [2,]  0.5 0.2500000
# >>       [,1]  [,2]  [,3]
# >> [1,] FALSE  TRUE  TRUE
# >> [2,] FALSE FALSE  TRUE
# >> [3,] FALSE FALSE FALSE
# >>      [,1] [,2] [,3]
# >> [1,]    1    4    7
# >> [2,]    2    5    8
# >> [3,]    3    6    9
